<div class="sm-pop">
    <div id="dialog_form" class="layui-form">

        <div class="layui-form-item">
            <label class="layui-form-label"><i>*</i> 名称</label>
            <div class="layui-input-block">
                <input type="text" name="title" lay-verify="required" maxlength="50" placeholder="请输入名称" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">跳转链接</label>
            <div class="layui-input-block">
                <input type="text" name="imgUrl" maxlength="250" placeholder="请输入跳转链接" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="remark" maxlength="200" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>


        <fieldset class="layui-elem-field layui-field-title">
            <legend><i style="color: red">*</i> 轮播图 <span class="must">(必填)</span></legend>
        </fieldset>
        <div class="layui-form-item">
            <input type="hidden" lay-verify="required" name="imgPath">
            <div class="layui-upload-drag" id="uploader">
                <i class="layui-icon"></i>
                <p>点击上传，或将文件拖拽到此处</p>
            </div>
        </div>

    </div>
</div>



<script>
    layui.use(["upload"], function () {
        var upload = layui.upload;
        var form = layui.form;


        form.render();
        //单图
        upload.render({
            elem: '#uploader',
            url: '/managerImg/uploadFileImg',
            size: 5120,//KB,0或默认不限制
            done: function (result, index, upload) {
                if (result.success && result.data) {

                    console.log(result);

                    $("#uploader").html("<img src='" + result.data + "' style='width: 200px;height:200px;'/><p>点击重新上传，或将文件拖拽到此处</p>");
                    $("#dialog_form input[name=imgPath]").val(result.data);
                } else {
                    layer.msg('上传失败');
                }
            }
        });
    })
</script>
